/**
 * SEVAS - Swiss Electronic Vaccination Advisor Service / Agile Development
 *
 * $Id: Vaccination.java 29 2010-08-18 16:51:14Z zimmr7@bfh.ch $
 */
package ch.bfh.sevas.gui;

import ch.bfh.sevas.DateConverter;
import java.awt.Component;
import java.util.Date;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableCellEditor;

public class DateCellEditor extends AbstractCellEditor implements TableCellEditor {

    private JTextField textField;
    private DateConverter dateConverter;

    public DateCellEditor() {
        textField = new JTextField();
        dateConverter = new DateConverter();
    }
    public Object getCellEditorValue() {
        return dateConverter.convertReverse(textField.getText());
    }
    public Component getTableCellEditorComponent(JTable table, Object value,
            boolean isSelected, int row, int column) {
        textField.setText(dateConverter.convertForward((Date) value));
        return textField;
    }
}